# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo_1724.1
# Description:
# Author:       yzl
# Date:         2019-05-11
#-------------------------------------------------------------------------------
import _thread as thread

txt = ''
data = ''
# 获取页面
def get_page_html(url,lock):
    # todo
    global txt
    print('lock1')
    txt = '1111111'
    lock.release()



# 解析页面
def parse_page(lock):
    global data
    #if txt:
    print('lock2')
    data = '9999'
    lock.release()

# 保存数据
def save_data(lock):
    # todo
    #if data:
    global data
    # if data:
    print('saved')
    lock.release()

def main():
    lock1 = thread.allocate_lock()
    lock1.acquire()

    url = 'http://clickc.admaster.com.cn/c/a122592,b3191400,c299,i0,m101,8a1,8b3,h,uhttps://sale.vmall.com/pseries2.html?cid=70146'
    thread.start_new_thread(get_page_html, (url, lock1))


    lock2 = thread.allocate_lock()
    lock2.acquire()
    thread.start_new_thread(parse_page, (lock2,))

    lock3 = thread.allocate_lock()
    lock3.acquire()
    thread.start_new_thread(save_data, (lock3,))

    while lock1.locked() or lock2.locked() or lock3.locked():
        pass

if __name__ == '__main__':
    main()
    print('over')
